<?php
namespace Admin\Controller;
use Think\Controller;
/**
* MenuItemController
*/
class MenuitemController extends Controller
{
	public function index()
	{
		echo MODULE_NAME . '/' . CONTROLLER_NAME . "/" . ACTION_NAME;
	}
	public function add()
	{
		//链接的生成
		
		$menuitem = D('Menuitem');

		$list = $menuitem->field("id,name,pid,path,concat(path,'-',id) AS bpath")->order('bpath,id')->where('menuid=1')->select();
		foreach ($list as $key => $value) {
			$list[$key]['signnum'] = count(explode('-', $value['bpath'])) - 1;
			$list[$key]['marginnum'] = (count(explode('-', $value['bpath'])) - 1) * 20;
		}
		$this->assign('milist',$list);
		$this->display();
	}
	public function insert()
	{
		$menuitem = D('Menuitem');
		$data = $menuitem->create();
		dump($data);
		$menuitem->add();
	}
	public function component()
	{
		$comid = I('get.comid');
		$com = M('Component');
		if (!empty($comid)) {
			$data = $com->getById($comid);
			$this->redirect(MODULE_NAME.'/'.$data['link'].'/helper');
		} else {
			$list = $com->where('enabled=1')->select();
			$this->assign('comlist',$list);
			$this->display();
		}
	}
}